import java.util.StringJoiner;

public class stringjoinerTest {
    public static void main(String[] args) {

        //创建对象
        StringJoiner sj=new StringJoiner("--");
        StringJoiner sj1=new StringJoiner(",","[","]");

        //添加元素
        sj.add("aaa").add("bbb").add("ccc");
        sj1.add("aa").add("bb").add("cc");

        //打印结果
        System.out.println(sj);//aaa--bbb--ccc
        System.out.println(sj1);//[aa,bb,cc]
    }
}
